
/**
*      author: Y_Yao
*      created: 2025-02-15 20:24:28
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
int N,M;
unordered_map<int, int> m1;
int ans = 0;

void solve()
{
    cin >> N >> M;
    for (int i = 0; i < M; ++i) 
    {
        int u, v;
        cin >> u >> v;
        if (u == v)
        {
            ans++; 
        } else 
        {
            int a = min(u, v);
            int b = max(u, v);
            m1[(a) * (N + 1) + b]++;
        }
    }
    
    int ret = 0;
    for (auto& e : m1) {
        int cnt = e.second;
        if (cnt > 1) {
            ret += cnt - 1;
        }
    }
    
    cout << ans + ret << endl;
        
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}